<?php
/*
	Install Uninstall Upgrade AutoStat System Code
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
	exit('Access Denied');
}
if(file_exists("source/plugin/dz_1/dz_1.inc.php")){
    $sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `sccj`  varchar(255) NOT NULL" ;
    DB::query($sql,'SILENT');
    $sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `cpgg`  varchar(255) NOT NULL" ;
    DB::query($sql,'SILENT');
    $sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `fyts`  varchar(255) NOT NULL" ;
    DB::query($sql,'SILENT');
    $sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `ysqz`  varchar(255) NOT NULL" ;
    DB::query($sql,'SILENT');
    $sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `hdtj`  varchar(255) NOT NULL" ;
    DB::query($sql,'SILENT');
	$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `ext_num`  int(11) NOT NULL" ;
    DB::query($sql,'SILENT');
	$sql ="ALTER TABLE ".DB::table('aljbd_goods_order')." ADD `ext_num`  int(10) NOT NULL" ;
	DB::query($sql,'SILENT');
    $sql ="ALTER TABLE ".DB::table('aljbd_goods_order_list')." ADD `ext_num`  int(10) NOT NULL" ;
    DB::query($sql,'SILENT');
    $sql ="ALTER TABLE ".DB::table('aljgwc')." ADD `ext_num`  int(10) NOT NULL" ;
    DB::query($sql,'SILENT');
}
$sql ="ALTER TABLE ".DB::table('aljbd_consume')." ADD `full` decimal(10,2) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_consume')." ADD `reduction` decimal(10,2) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `btypeid`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `bsubtypeid`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `attr_key` text NOT NULL ;" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `attr_value` text NOT NULL ;" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `attr_sku` text NOT NULL ;" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." CHANGE `price2` `price2` DECIMAL( 10, 2 ) NOT NULL " ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." CHANGE `price1` `price1` DECIMAL( 10, 2 ) NOT NULL " ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd')." ADD `rubbish`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `rubbish`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_notice')." ADD `rubbish`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_consume')." ADD `rubbish`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_album')." ADD `rubbish`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_album_attachments')." ADD `rubbish`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_page')." ADD `rubbish`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_comment')." ADD `rubbish`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_comment_consume')." ADD `rubbish`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_comment_notice')." ADD `rubbish`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');

$sql ="ALTER TABLE ".DB::table('aljbd_comment_goods')." ADD `rubbish`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_video')." ADD `rubbish`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');

$sql ="ALTER TABLE ".DB::table('aljbd')." ADD `madv`  varchar(255) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd')." ADD `madvurl`  varchar(255) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd')." ADD `wangwang`  varchar(100) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd')." ADD `weixin_id`  varchar(100) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `fare_desc`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd')." ADD `collection`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `collection`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_notice')." ADD `collection`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_consume')." ADD `collection`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `state`  tinyint(3) NOT NULL" ;
if(DB::query($sql,'SILENT')){print('aljbd_goods add state succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `fare` decimal(8,2) NOT NULL" ;
if(DB::query($sql,'SILENT')){print('aljbd_goods add fare succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_type_goods')." ADD `logo` varchar(255) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_type_goods')." ADD `brand_id` text NOT NULL ;" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_type_goods')." ADD `type_ad` text NOT NULL ;" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `selling_point`  VARCHAR( 255 ) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `category`  tinyint(3) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `commodity_type`  tinyint(3) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `starttime`  int(11) NOT NULL" ;
DB::query($sql,'SILENT');
$sql = "CREATE TABLE IF NOT EXISTS ".DB::table('aljbd_type_brand')." (
`id` mediumint(9) unsigned NOT NULL AUTO_INCREMENT,
  `upid` mediumint(9) unsigned NOT NULL,
  `subid` varchar(255) NOT NULL,
  `subject` varchar(255) NOT NULL,
  `displayorder` mediumint(9) unsigned NOT NULL,
  `bid` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `bid` (`bid`),
  KEY `upid` (`upid`)
);";
if(DB::query($sql,'SILENT')){print('create table `aljbd_type_brand` succeed!<br>');}
$sql = "CREATE TABLE IF NOT EXISTS ".DB::table('aljbd_search_keyword')." (
`id` int(11) NOT NULL AUTO_INCREMENT,
  `uid` int(11) NOT NULL,
  `username` varchar(255) NOT NULL,
  `keyword` varchar(255) NOT NULL,
  `timestamp` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `keyword` (`keyword`)
);";
if(DB::query($sql,'SILENT')){print('create table `aljbd_search_keyword` succeed!<br>');}
$sql = "CREATE TABLE IF NOT EXISTS ".DB::table('aljbd_goods_settle')." (
  `settleid` varchar(255) NOT NULL,
  `username` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `account` varchar(255) NOT NULL,
  `settleprice` varchar(255) NOT NULL,
  `payment` tinyint(3) NOT NULL,
  `status` tinyint(3) NOT NULL,
  `applytime` int(11) NOT NULL,
  `dateline` int(11) NOT NULL,
  `uid` int(10) NOT NULL,
  PRIMARY KEY (`settleid`)
);";
if(DB::query($sql,'SILENT')){print('create table `aljbd_goods_settle` succeed!<br>');}

$sql ="ALTER TABLE ".DB::table('aljbd')." CHANGE `x` `x` DECIMAL( 10, 6 ) NOT NULL " ;
if(DB::query($sql,'SILENT')){print(' CHANGE x succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd')." CHANGE `y` `y` DECIMAL( 10, 6 ) NOT NULL " ;
if(DB::query($sql,'SILENT')){print(' CHANGE y succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_order')." ADD `payment` char(50) NOT NULL" ;
DB::query($sql,'SILENT');
$sql = "CREATE TABLE IF NOT EXISTS ".DB::table('aljbd_attr')." (
  `mid` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `tid` int(10) unsigned NOT NULL,
  `name` int(10) NOT NULL,
  `content` text,
  `addtime` int(10) unsigned NOT NULL,
  `typeid` int(10) NOT NULL,
  PRIMARY KEY (`mid`)
);";
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd')." ADD `subtype3`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `subtype3`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `displayorder`  int(10) NOT NULL" ;
DB::query($sql,'SILENT');
$sql ="ALTER TABLE ".DB::table('aljbd_user')." ADD `addr`  varchar(255) NOT NULL" ;
if(DB::query($sql,'SILENT')){print('add addr succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_user')." ADD `qq`  BIGINT NOT NULL" ;
if(DB::query($sql,'SILENT')){print('add qq succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_user')." ADD `tel`  BIGINT NOT NULL" ;
if(DB::query($sql,'SILENT')){print('add tel succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_order')." ADD `d`  tinyint(3) NOT NULL" ;
if(DB::query($sql,'SILENT')){print('add tel succeed!<br>');}
$sql = "CREATE TABLE IF NOT EXISTS ".DB::table('aljbd_kami')." (
  `mid` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `sid` int(10) unsigned NOT NULL,
  `message` text,
  `uid` mediumint(8) unsigned NOT NULL,
  `username` varchar(100) NOT NULL,
  `addtime` int(10) unsigned NOT NULL,
  `dateline` int(10) unsigned NOT NULL,
  `orderid` varchar(255) NOT NULL,
  PRIMARY KEY (`mid`)
);";
DB::query($sql,'SILENT');
$sql = "CREATE TABLE IF NOT EXISTS `pre_aljbd_emaillog` (
  `id` int(10) NOT NULL auto_increment,
  `sendemail` varchar(255) NOT NULL,
  `sendtype` tinyint(3) NOT NULL,
  `sendtime` int(10) NOT NULL,
  `success` tinyint(3) NOT NULL,
  PRIMARY KEY  (`id`)
);";
if(DB::query($sql,'SILENT')){print('create table pre_aljbd_emaillog succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_order')." ADD `remarks`  varchar(255) NOT NULL" ;
if(DB::query($sql,'SILENT')){print('add remarks succeed!<br>');}

$sql ="ALTER TABLE ".DB::table('aljbd')." ADD `business_hours`  varchar(255) NOT NULL" ;
if(DB::query($sql,'SILENT')){print('add business_hours succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd')." ADD `bus_routes`  varchar(255) NOT NULL" ;
if(DB::query($sql,'SILENT')){print('add bus_routes succeed!<br>');}

$sql ="ALTER TABLE ".DB::table('aljbd_region')." ADD `displayorder`  int(10) NOT NULL" ;
if(DB::query($sql,'SILENT')){print('add displayorder succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd')." ADD `businesstype`  varchar(255) NOT NULL" ;
if(DB::query($sql,'SILENT')){print('add businesstype succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_consume')." ADD `draw`  varchar(255) NOT NULL" ;
if(DB::query($sql,'SILENT')){print('add draw succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `amount` INT NOT NULL ;" ;
if(DB::query($sql,'SILENT')){print('add amount succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `buyamount` INT NOT NULL ;" ;
if(DB::query($sql,'SILENT')){print('add buyamount succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `endtime` INT NOT NULL ;" ;
if(DB::query($sql,'SILENT')){print('add endtime succeed!<br>');}

$sql ="ALTER TABLE ".DB::table('aljbd_consume')." ADD `sign` INT NOT NULL ;" ;
if(DB::query($sql,'SILENT')){print('add sign succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_notice')." ADD `subtype` INT NOT NULL ;" ;
if(DB::query($sql,'SILENT')){print('add subtype succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_notice')." ADD `type` INT NOT NULL ;" ;
if(DB::query($sql,'SILENT')){print('add type succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_consume')." ADD `subtype` INT NOT NULL ;" ;
if(DB::query($sql,'SILENT')){print('add subtype succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_consume')." ADD `type` INT NOT NULL ;" ;
if(DB::query($sql,'SILENT')){print('add type succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_consume')." CHANGE `jieshao` `jieshao` MEDIUMTEXT  NOT NULL" ;
if(DB::query($sql,'SILENT')){print(' CHANGE jieshao succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd')." ADD `region1`  varchar(255) NOT NULL" ;
if(DB::query($sql,'SILENT')){print('add region1 succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd')." ADD `qrcode`  varchar(255) NOT NULL" ;
if(DB::query($sql,'SILENT')){print('add qrcode succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_attestation')." CHANGE `tel` `tel` VARCHAR( 255 ) NOT NULL" ;
if(DB::query($sql,'SILENT')){print(' CHANGE tel succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `subtype` INT NOT NULL ;" ;
if(DB::query($sql,'SILENT')){print('add subtype succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `type` INT NOT NULL ;" ;
if(DB::query($sql,'SILENT')){print('add type succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `sign` INT NOT NULL ;" ;
if(DB::query($sql,'SILENT')){print('add sign succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd')." ADD `wurl` varchar(255) NOT NULL ;" ;
if(DB::query($sql,'SILENT')){print('add wurl succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd_goods')." ADD `gwurl` varchar(255) NOT NULL ;" ;
if(DB::query($sql,'SILENT')){print('add gwurl succeed!<br>');}
//finish to put your own code
$sql ="ALTER TABLE ".DB::table('aljbd')." ADD `qq`  BIGINT NOT NULL" ;
if(DB::query($sql,'SILENT')){print('add qq succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd')." ADD `displayorder` INT NOT NULL" ;
if(DB::query($sql,'SILENT')){print('add displayorder succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd')." ADD `price` DECIMAL( 10, 2 ) NOT NULL" ;
if(DB::query($sql,'SILENT')){print('add price succeed!<br>');}
$sql ="ALTER TABLE ".DB::table('aljbd')." ADD `orderid` char( 32 ) NOT NULL" ;
if(DB::query($sql,'SILENT')){print('add orderid succeed!<br>');}

echo '<br/>repair succeed';
?>
